class LoginForm {
    constructor() {
        this.state = 'hide';
    }
    show() {
        if (this.state === 'show') {
            alert('已经显示');
            return
        }
        this.state = 'show';
        console.log('登录框显示成功')
    }
    hide() {
        if (this.state === 'hide') {
            alert('已经隐藏');
            return
        }
        this.state = 'hide';
        console.log('登录框隐藏成功');
    }

    static getInstance() {
        if (!LoginForm.instance) {
            LoginForm.instance = new LoginForm();
        }
        return LoginForm.instance;
    }
}

// 测试代码
let login1 = LoginForm.getInstance();
login1.show();
let login2 = LoginForm.getInstance();
login2.hide();
let login3 = LoginForm.getInstance();
login3.hide();